<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>游戏</title>
</head>

<body>
    <script>
           console.log("========欢迎来我的宠物游戏===========")


           //登录的第一步

           var oLoginMyPet = function(){

            console.log("登录")
            do{
                var nickname = prompt("请输入昵称")
            }while(nickname.trim().length === 0)

            do{
                var password = password("请输入密码")
            }while(password.trim().length  < 6 )
            if(nickname,password){
                console.log("登录成功")
            } else{
                console.log("登录失败，用户名或者密码错误")
            }




           }
    



           console.log("============================================")
        //注册的第一步
        var  oRegisterMyPet = function(){
            console.log("注册")
            do{
                var nickname = prompt("请输入昵称")
            }while(nickname.trim().length === 0)

            do{
                var password = password("请输入密码")
            }while(password.trim().length  < 6 )


            do{
                var password_confirm = password_confirm("请再次输入密码")
            }while( password_confirm !== password )

            console.log(nickname,password)


        }


        console.log("============================================")
        var showWelocomeMyPet = function () {
            var result = prompt("1.注册   2. 登录  3.退出")
            switch (result) {
                case "1":
                oRegisterMyPet()
                    break;
                case "2":
                    console.log("登录")
                    break;
                case "3":
                    console.log("退出")
                    break;
                default:
                    console.log("输入有误")
                    arguments.callee() // showWelocomeMyPet() //不建议直接用 showWelcomeMyPet() 可以直接用代表自身调用
                    //输入有误 要重新再走一遍 所以就在用function调用
                    break;
            }
        }

       


        showWelocomeMyPet()
    </script>

</body>

</html>